<?php 
require_once("konf.php"); 


	if(isSet($_REQUEST["paku"])){
		$kask=$yhendus->prepare("UPDATE mikrobussivedu SET pakkuminetehtud=1 WHERE id=?");
		echo $yhendus->error;
		$kask->bind_param("i", $_REQUEST["paku"]);
		$kask->execute();
	}
	if(isSet($_REQUEST["kustuta"])){
		$kask=$yhendus->prepare("DELETE FROM mikrobussivedu WHERE id=?");
		$kask->bind_param("i", $_REQUEST["kustuta"]);
		$kask->execute();
	}
	$kask=$yhendus->prepare("SELECT id, kliendinimi, kontakt, kliendisoov 
	FROM mikrobussivedu WHERE pakkuminetehtud=0");
	$kask->bind_result($id, $kliendinimi, $kontakt, $kliendisoov);
	$kask->execute();
?>

<!doctype html>
<html>
	<head>
		<title>Pakkumise tegemine</title>
	</head>
	<body>
		<?php
		require("tagasi.html")
		?>
		<table>
		<?php
		while($kask->fetch()){
			echo "
			<tr>
			<td>$kliendinimi</td>
			<td>$kontakt</td>
			<td>$kliendisoov</td>
			<td><form action=''>
			<td><a href='?paku=$id'>Tee pakkumine</a></td>
			<td><a href='?kustuta=$id'>Kustuta</a></td>
			</form>
			</td>
			</tr>
			";
		}
		?>
		</table>
	</body>
</html>